<template>
	<view class="p20">
		<u-navbar :isBack="false" :background="{background: '#0000'}" :border-bottom="false" />
		<view class="h60"></view>
		<view class="radius20 bg-fff p30 loginBoxShadow">
			<view class="flex mb30">
				<image :src="$config.shop_logo||''" class="h92 w92 radius20" mode=""></image>
				<view class="fs36 fw-600 ml24">
					{{$params.type?'绑定手机号':'账号密码注册'}}
				</view>
			</view>
			<u-form :borderBottom="false">
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.mobile" maxlength="11" placeholder="请输入手机号码"></u-input>
					</view>
				</u-form-item>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20 flex row-between">
						<u-input v-model="form.code" class="flex1" placeholder="请输入短信验证码"></u-input>
						<tips :mobile="form.mobile" type="register"></tips>
					</view>
				</u-form-item>
				<block v-if="!$params.type">
					<u-form-item>
						<view class="p10 pl30 pr30 w-max bg-f8f radius20">
							<u-input v-model="form.login_pwd" type="password" placeholder="请输入登录密码"></u-input>
						</view>
					</u-form-item>
					<u-form-item>
						<view class="p10 pl30 pr30 w-max bg-f8f radius20">
							<u-input v-model="form.login_pwd2" type="password" placeholder="请确认登录密码"></u-input>
						</view>
					</u-form-item>
				</block>
				<u-form-item>
					<view class="p10 pl30 pr30 w-max bg-f8f radius20">
						<u-input v-model="form.regcode" type="text" :disabled="$params.disabled"
							placeholder="请输入上级邀请码"></u-input>
					</view>
				</u-form-item>
			</u-form>
			<u-button type="warning" class="mt50 radius20" ripple @click="submit">提交</u-button>
			<view class="flex row-center mt40 color-999" v-if="!$params.type">
				<view class="" @click="$tool.reUrl('./login')">去登录</view>
			</view>

			<view class="flex fs24 mt20" @click="isLook=!isLook">
				<radio :checked="isLook" class="scale7 pe-none" :color="$zs"  />
				<view class="color-999">已阅读并同意</view>
				<view class="color-zs" @click.stop="$jump('/pages/public/text',{text:'master_pact',tit:'陪诊师协议'})">
					《陪诊师协议》</view>
				<view class="color-999">与</view>
				<view class="color-zs" @click.stop="$jump('/pages/public/text',{text:'privacy_pact',tit:'隐私政策'})">
					《隐私政策》
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLook: false,
				form: {
					mobile: '',
					code: '',
					login_pwd: '',
					login_pwd2: '',
					regcode: ''
				}
			};
		},
		onLoad(e) {
			this.form.regcode = e.regcode || uni.getStorageSync('regcode') || ""
		},
		methods: {
			submit() {
				this.register()
			},
			register(userInfo = '') {
				if (!this.isLook) return this.$msg('请先同意协议')
				let params = {
					...this.$params,
					...this.form,
				}
				this.$request('/master/login/setPwd', params).then(res => {
					this.$login_success(res, 'back')
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		min-height: 100%;
		background: linear-gradient(145deg, rgba(253, 52, 52, 0.07) 0%, rgba(255, 255, 255, 0.1200) 35%, rgba(0, 212, 235, 0.10) 100%);
	}
</style>